package controller.admin.employee;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import model.DTO.EmployeeUpdateDTO;
import service.Impl.EmployeeServiceImpl;
import util.GetJsonUtil;
import util.ResultUtil;

import java.io.IOException;
@WebServlet("/admin/employee/update")
public class EmployeeUpdateController extends HttpServlet {
    //修改员工信息
    @Override
    protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        EmployeeUpdateDTO e= (EmployeeUpdateDTO) GetJsonUtil.get(req,new EmployeeUpdateDTO());
        EmployeeServiceImpl employeeService=new EmployeeServiceImpl();
        employeeService.Update(e.getId(),e.getIdNumber(),e.getName(),e.getPhone(),e.getGender(),e.getUsername());

        String json=ResultUtil.getJSON(null);
        resp.getWriter().write(json);
        resp.getWriter().write("修改成功!");
    }
}
